# 定义
CXX = g++
CXXFLAGS = -std=c++11 -O2 -march=native -I./include -I./third_party
BUILD_DIR = build
TARGET = $(BUILD_DIR)/preprocess

# 默认: 编译并运行，生成output.png
all: run

# 编译
$(TARGET): $(BUILD_DIR)
	$(CXX) $(CXXFLAGS) src/*.cpp third_party/lodepng.cpp -o $@

$(BUILD_DIR):
	mkdir -p $(BUILD_DIR)

# 运行主程序
run: $(TARGET)
	./$(TARGET)

# 编译运行+可视化
view: run
	python tools/edge_visualize.py --image assets/input.png --edges assets/edges_debug.csv --crop-csv assets/adaptive_crop.csv --output assets/edges_visualized.png	

# 仅运行python可视化
python:
	python tools/edge_visualize.py --image assets/input.png --edges assets/edges_debug.csv --crop-csv assets/adaptive_crop.csv --output assets/edges_visualized.png

# 清理
clean:
	rm -rf $(BUILD_DIR)

.PHONY: all run view python clean

